package com.ruoyi.web.controller.Base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.domain.AbilityServer;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.service.IAbilityServerService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代理服务Controller
 * 
 * @author ruoyi
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/system/aserver")
public class AbilityServerController extends BaseController
{
    @Autowired
    private IAbilityServerService abilityServerService;

    /**
     * 查询代理服务列表
     */

    @GetMapping("/list")
    public TableDataInfo list(AbilityServer abilityServer)
    {
        startPage();
        List<AbilityServer> list = abilityServerService.selectAbilityServerList(abilityServer);
        return getDataTable(list);
    }
    @PostMapping("/change")
    public AjaxResult changeHost(@RequestBody AbilityServer abilityServer)
    {
        return toAjax(abilityServerService.changeHost(abilityServer));
    }

    /**
     * 导出代理服务列表
     */

    @Log(title = "代理服务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AbilityServer abilityServer)
    {
        List<AbilityServer> list = abilityServerService.selectAbilityServerList(abilityServer);
        ExcelUtil<AbilityServer> util = new ExcelUtil<AbilityServer>(AbilityServer.class);
        util.exportExcel(response, list, "代理服务数据");
    }

    /**
     * 获取代理服务详细信息
     */

    @GetMapping(value = "/get")
    public AjaxResult getInfo(@RequestParam(value = "id") String id)
    {
        return success(abilityServerService.selectAbilityServerByID(id));
    }

    /**
     * 新增代理服务
     */

    @Log(title = "代理服务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AbilityServer abilityServer)
    {
        return toAjax(abilityServerService.insertAbilityServer(abilityServer));
    }

    /**
     * 修改代理服务
     */

    @Log(title = "代理服务", businessType = BusinessType.UPDATE)
    @PutMapping("/update")
    public AjaxResult edit(@RequestBody AbilityServer abilityServer)
    {
        return toAjax(abilityServerService.updateAbilityServer(abilityServer));
    }

    /**
     * 删除代理服务
     */

    @Log(title = "代理服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(abilityServerService.deleteAbilityServerByIDs(IDs));
    }
}
